public class Divide {
	static StringBuffer whiteSpace = new StringBuffer();

	public static void main(String[] args) {

		checkArguments(args);

		String stringNumber = args[0];
		String stringDivider = args[1];
		int digitNumber = new Integer(stringNumber);
		int digitDivider = new Integer(stringDivider);
		Integer intDigit = 0;
		int counterDigit = 0;
		int[] numberArray = converterStringToArray(stringNumber);
		int result = numberArray[0];
		String stringDigit = "";

		System.out.format("%s%d %s %d\n", " ", digitNumber, "|", digitDivider);
		System.out.format("%s\n", "      |------");
		System.out.format("%s %d\n", "\t", (digitNumber / digitDivider));

		for (int k = 0; k < numberArray.length; k++) {

			if (result <= digitDivider) {
				if (counterDigit == numberArray.length - 1) {
					stringDigit = "" + result;
				} else {
					stringDigit = "" + result + numberArray[++counterDigit];
				}
				intDigit = new Integer(stringDigit);
				result = intDigit / digitDivider;
				if ((intDigit - digitDivider) >= 0) {
					System.out.println(whiteSpace + " " + intDigit);
					System.out
							.println(whiteSpace + "-" + result * digitDivider);
				}
				result = intDigit - (result * digitDivider);
				if (k == numberArray.length - 1) {
					System.out.println(whiteSpace + " " + result);
				}
				addSpace(result);
			} else {
				if (k != numberArray.length) {
					System.out.println(whiteSpace + " " + result);
				}
				stringDigit = "" + result;
				intDigit = new Integer(stringDigit);
				result = intDigit / digitDivider;
				System.out.println(whiteSpace + "-" + result * digitDivider);
				result = intDigit - (result * digitDivider);
				if (k == numberArray.length - 1) {
					System.out.println(whiteSpace + " " + result);
				}
				addSpace(result);
			}
		}
	}

	public static void checkArguments(String[] args) {
		if ((args.length < 1)) {
			System.out.println("Bad arguments, enter correct arguments.");
			return;
		} else {
			if (args[0].length() <= 2) {
				System.out.println("Bad arguments, enter correct arguments.");
				return;
			}
		}
	}

	public static void addSpace(int num) {
		whiteSpace.append(" ");
		if (num == 0) {
			whiteSpace.append(" ");
		}
	}

	public static int[] converterStringToArray(String str) {
		int[] array = new int[str.length()];
		for (int i = 0; i < array.length; i++) {
			Integer orderedDigit = new Integer(str.substring(i, i + 1));
			array[i] = orderedDigit;
		}
		return array;
	}
